﻿@model TidyBlog.MVC.WWW.Models.ListWithPaginator<TidyBlog.Entity.User>

@{
	ViewBag.Title = "用户管理";
	Layout = "~/Views/Shared/_ManageLayout.cshtml";
}

<form action="@Url.Content("List")" method="get">
	<table class="cols-4">
		<thead>
			<tr>
				<th colspan="4">用户搜索</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="4" class="buttons">
					<input type="submit" value="搜 索" />
					<input type="reset" value="清 空" data-isclear="true" />
				</td>
			</tr>
		</tfoot>
		<tbody>
			<tr>
				<th><label for="username">用户名：</label></th>
				<td><input type="text" id="username" name="username" maxlength="20" value="@Model.SearchParams["username"]" /></td>
				<th><label for="nickname">昵称：</label></th>
				<td><input type="text" id="nickname" name="nickname" maxlength="20" value="@Model.SearchParams["nickname"]" /></td>
			</tr>
		</tbody>
	</table>
</form>

@if (Model.Result != null)
{
<table>
	<thead>
		<tr>
			<th style="width: 7%;">编号</th>
			<th style="width: 20%;">用户名</th>
			<th style="width: 20%;">昵称</th>
			<th style="width: 20%;">注册时间</th>
			<th style="width: 20%;">最后活动时间</th>
			<th style="width: 13%;">操作</th>
		</tr>
	</thead>
	@if (Model.Result.Data.Count > 1)
	{
	<tfoot>
		<tr><td colspan="6">@{ Html.RenderPartial("_paginator", Model.ResultPaginator); }</td></tr>
	</tfoot>
	}
	<tbody>
	@if (Model.Result.Data == null || Model.Result.Data.Count == 0)
	{
		<tr><td colspan="6">暂无符合条件的数据</td></tr>
	}
	else
	{
		foreach (var user in Model.Result.Data)
		{
			var routeValues = new { id = user.UserId };
		<tr>
			<td>@user.UserId</td>
			<td>@user.UserName</td>
			<td>@user.Nickname</td>
			<td style="text-align: center;">@user.RegTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
			<td style="text-align: center;">@user.LastActivity.AddHours(ViewBag.Setup.TimeZone).ToString("yyyy-MM-dd HH:mm:ss")</td>
			<td style="word-spacing: 1em; text-align: center;">
				<a href="@Url.Action("Edit", routeValues)">编辑</a>
				<a href="@Url.Action("Delete", routeValues)" class="delete-confirm">删除</a>
			</td>
		</tr>
		}
	}
	</tbody>
</table>
}

@section Script{
<script>
require('dom/1.0.x/', function($) {
	$('a.delete-confirm').click(function(e) {
		if ( !window.confirm('确认要删除此用户吗（此操作不可恢复）？') ) {
			e.preventDefault();
		}
	});
});
</script>
}